# -*- coding: utf-8 -*-
# @Time     : 2021/4/14 17:31
# @Author   : pengrenjie
# @Email    : 941257162@.com
# @File     : prj.py
import random
import string
def ran():
    with open("passwd.txt","w+",encoding='utf-8') as fp:
        while 1:
            N = input("需要生成几个激活码(按Q退出)：")
            if N == 'Q':
                break
            elif N.isdigit():
                for i in range(int(N)):
                    passwd = ''.join(random.sample(string.ascii_letters + string.digits, 32)).upper()
                    print(f"第{i+1}个激活码:{passwd}")
                    fp.write(f"第{i+1}个激活码:{passwd}\n")
                break

            else:
                print("输入不合法，请重新輸入")
print(__name__)